﻿
Public Class main

    Public g_Graphic As Graphics
    Public g_Canvas As Canvas

    Private Sub main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.KeyPreview = True
        g_Graphic = pnlMainClient.CreateGraphics
        g_Canvas = New Canvas
        g_Canvas.SetRect(0, 0, pnlMainClient.Width, pnlMainClient.Height)
        Dim rect As New FigureRect
        g_Canvas.Add(rect)
        rect.SetRect(0, 0, 200, 200)

        Dim rect2 As New FigureEllipse
        g_Canvas.Add(rect2)
        rect2.SetRect(100, 100, 200, 200)

        Dim img As New FigureImage(300, 300, 100, 100)
        g_Canvas.Add(img)
        img.SetImage("E:\DOC\IMAGE\pcb.png")

    End Sub

    Private Sub toolbar_figure_ItemClicked(sender As System.Object, e As System.Windows.Forms.ToolStripItemClickedEventArgs)

    End Sub

    Private Sub toolbar_figure_ItemClicked_1(sender As System.Object, e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles toolbar_figure.ItemClicked

    End Sub

    Private Sub TabPage1_Click(sender As System.Object, e As System.EventArgs)

    End Sub

    Private Sub TreeView1_AfterSelect(sender As System.Object, e As System.Windows.Forms.TreeViewEventArgs) Handles tree_menu.AfterSelect

    End Sub

    Private Sub pnlMainClient_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles pnlMainClient.Paint
        RaiseEvent PaintEvent(sender, e)
    End Sub

    Private Sub tbSelect_Click(sender As System.Object, e As System.EventArgs)
        Dim fg As FigureElement = g_Canvas.m_FigureManager.m_FigureList.Item(0)
        fg.SetPropEx(fg.GetProp().clrForeColor, Color.Red, fg.GetProp().nLineWidth)

        g_Canvas.SetBackColorEx(Color.Black)
    End Sub

    Private Sub tbRect_Click(sender As System.Object, e As System.EventArgs) Handles tbRect.Click
        Dim fg As FigureElement = g_Canvas.m_FigureManager.m_FigureList.Item(0)
        fg.SetPropEx(fg.GetProp().clrForeColor, Color.White, fg.GetProp().nLineWidth)
        g_Canvas.SetBackColorEx(Color.White)
    End Sub

    Private Sub tbEllipse_Click(sender As System.Object, e As System.EventArgs) Handles tbEllipse.Click
        Dim fg As FigureImage = g_Canvas.m_FigureManager.m_FigureList.Item(2)
        fg.SetImage("E:\DOC\IMAGE\pcb.png")
        fg.RenderEx()
    End Sub

    Private Sub tbPolygon_Click(sender As System.Object, e As System.EventArgs) Handles tbPolygon.Click
        Dim fg As FigureImage = g_Canvas.m_FigureManager.m_FigureList.Item(2)
        fg.SetImage("E:\DOC\IMAGE\clock.png")
        fg.RenderEx()
    End Sub

    '------------------------------------------------------start 事件回调------------------------------------------------------'
    Public Shared Event PaintEvent As PaintHandler
    Delegate Sub PaintHandler(ByRef sender As System.Object, ByRef e As System.Windows.Forms.PaintEventArgs)

    Public Shared Event MouseDownEvent As MouseHandler
    Public Shared Event MouseUpEvent As MouseHandler
    Public Shared Event MouseMoveEvent As MouseHandler
    Delegate Sub MouseHandler(sender As System.Object, e As System.Windows.Forms.MouseEventArgs)

    Public Shared Event KeyDownEvent As KeyEventHandler
    Public Shared Event KeyUpEvent As KeyEventHandler
    Delegate Sub DeyHandler(sender As System.Object, e As System.Windows.Forms.KeyEventArgs)


    Private Sub pnlMainClient_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles pnlMainClient.MouseDown
        RaiseEvent MouseDownEvent(sender, e)

    End Sub

    Private Sub pnlMainClient_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles pnlMainClient.MouseMove
        RaiseEvent MouseMoveEvent(sender, e)
    End Sub

    Private Sub pnlMainClient_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles pnlMainClient.MouseUp
        RaiseEvent MouseUpEvent(sender, e)

    End Sub

    Private Sub main_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        RaiseEvent KeyDownEvent(sender, e)
    End Sub

    Private Sub main_KeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        RaiseEvent KeyUpEvent(sender, e)
    End Sub

    '------------------------------------------------------end 事件回调------------------------------------------------------'
End Class
